//
//  KKXuanShangDetailCell.m
//  DoMi
//
//  Created by 康凯 on 2016/12/6.
//  Copyright © 2016年 kk. All rights reserved.
//

#import "KKXuanShangDetailCell.h"
#import "KKComHttp.h"

@implementation KKXuanShangDetailCell

- (void)awakeFromNib {
    [super awakeFromNib];
    UITapGestureRecognizer *tap=[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(likeClick)];
    [self.likeView addGestureRecognizer:tap];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)initData:(KKQuestionDetailListM *)data{
    self.respondInfo=data;
    self.respondId=data.respondid;
    [self.avatar sd_setImageWithURL:[NSURL URLWithString:data.avatar] placeholderImage:[UIImage imageNamed:@"default_avater"]];
    if([KKAppUtils isEmptyString:data.nickname]){
        self.nickname.text=@"匿名";
    }else{
        self.nickname.text=data.nickname;
    }
    float width=[KKAppUtils sizeWithText:data.job font:[UIFont systemFontOfSize:12] maxSize:CGSizeMake(100, 14)].width;
    self.jobWidth.constant=width+5;
    self.job.text=data.job;
    self.content.text=data.respondcontent;
    self.time.text=data.respondtime;
    self.likeCount.text=data.likecoun;
    self.money.text=[NSString stringWithFormat:@"¥%@元",data.money];
//    if([data.money isEqualToString:@"0.00"]){
//        self.moneyView.hidden=YES;
//    }
}

#pragma mark 按钮--采纳
- (IBAction)adoptClick:(id)sender {
    [self commitAdopt];
}
#pragma mark 按钮--点赞
-(void)likeClick{
    [self commitLike];
}
#pragma mark 接口--点赞
-(void)commitLike{
    [KKComHttp questionLike:self.respondId success:^(id data) {
        [KKAppUtils toast:@"点赞成功"];
        self.likeCount.text=data;
        self.respondInfo.likecoun=data;
    } failure:^(NSError *error) {
        
    }];
}
#pragma mark 接口--采纳
-(void)commitAdopt{
    [KKComHttp questionAdopt:self.respondId success:^(id data) {
        [KKAppUtils toast:@"采纳成功"];
    } failure:^(NSError *error) {
        
    }];
}
@end
